package com.mac.demo.service;

import com.mac.demo.entity.AppUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;
import java.util.List;

@FeignClient(value = "user-center", fallback = AppUserService.AppUserHystrix.class)
public interface AppUserService
{
    @RequestMapping(value = "/api/appUser/findAll", method = RequestMethod.POST)
    public List<AppUser> findAll();

    @RequestMapping(value = "/api/appUser/findByToken", method = RequestMethod.POST)
    public AppUser findByToken(@RequestParam String token);


    @Component
    public class AppUserHystrix implements AppUserService
    {

        @Override
        public List<AppUser> findAll()
        {
            Date date=new Date();
            System.out.println(date.toString()+"findAll出现异常！请管理员尽快处理");
            return null;
        }

        @Override
        public AppUser findByToken(String token)
        {
            Date date=new Date();
            System.out.println(date.toString()+"findByToken出现异常！请管理员尽快处理");
            return null;
        }
    }
}
